<?php
class Resources extends CI_Model {
    function getResourcesFromCategory($category) {
        if (is_numeric($category)) {
            $sql = "SELECT * from fl_resources WHERE CategoryID = '$category' ORDER BY DateCreated DESC";
        } else {
            $sql = "SELECT CID from fl_categories WHERE CategoryNameLink = '$category'";
            $query = $this->db->query($sql);
            $row = $query->row_array();

            $sql = "SELECT * from fl_resources WHERE CategoryID = '".$row['CID']."' ORDER BY DateCreated DESC";
        }
        $query = $this->db->query($sql);

        if ($query->num_rows()>0) {
            return $query->result_array();
        } else {
            return false;
        }
    }
}
?>